﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Web;
using DataAccessLayer;

namespace ServiceLayer.Entity
{
    [DataContract]
    public class PurchaseOrderDetailW
    {
        int pODetailID;
        int pOID;
        string itemCode;
        int pOQty;

        [DataMember]
        public int PODetailID
        {
            get { return pODetailID; }
            set { pODetailID = value; }
        }

        [DataMember]
        public int POID
        {
            get { return pOID; }
            set { pOID = value; }
        }

        [DataMember]
        public string ItemCode
        {
            get { return itemCode; }
            set { itemCode = value; }
        }

        [DataMember]
        public int POQty
        {
            get { return pOQty; }
            set { pOQty = value; }
        }

        public static PurchaseOrderDetailW convert(PurchaseOrderDetail purchaseOrderDetail)
        {
            PurchaseOrderDetailW u = new PurchaseOrderDetailW();

            u.pODetailID = purchaseOrderDetail.PODetailID;
            u.POID = purchaseOrderDetail.POID.GetValueOrDefault();
            u.ItemCode = purchaseOrderDetail.ItemCode;
            u.POQty = purchaseOrderDetail.POQty.GetValueOrDefault();
            return u;
        }

        public static List<PurchaseOrderDetailW> convertList(List<PurchaseOrderDetail> list)
        {
            List<PurchaseOrderDetailW> listW = new List<PurchaseOrderDetailW>();

            foreach (PurchaseOrderDetail x in list)
            {
                listW.Add(convert(x));
            }
            return listW;
        }
    }
}